package com.hy.day;

/**
 * Created With IntelliJ IDEA.
 * Descriptions:
 * User:Mr.Du
 * Date:2024/8/21
 * Time:10:09
 */
public class FindMaximumNumber {

    public long findMaximumNumber(long k, int x) {
        long res = 0, t = 0;
        for(long i = 1;i <= k;i++){
            long s = i;
            for(int j = 0;j < 32;j++){
                if(x == 1){
                    t += s & 1;
                    s = s >> x;
                }else{
                    t += (s >> x) & 1;
                    s = s >> x;
                }
            }
            res = Math.max(res, t);
            if(res > k){
                return i - 1;
            }
        }
        return res;
    }

    public static void main(String[] args) {
        Integer.bitCount(10);
        System.out.println(Integer.bitCount(10));
        System.out.println(10 >> 2);
    }
}
